/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.quickorm.dao;

/**
 *
 * @author aaa
 */
public class DataAccessException
        extends RuntimeException {

    private String sql;

    /**
     * 获取SQL字符串
     *
     * @return
     */
    public String getSql() {
        return sql;
    }

    /**
     * 设置SQL字符串
     *
     * @param sql
     */
    public void setSql(String sql) {
        this.sql = sql;
    }

    @Override
    public String getMessage() {
        String message = null;
        Throwable currentThrowable = this.getCause();
        while (message == null) {
            if (currentThrowable == null) {
                break;
            }
            message = currentThrowable.getMessage();
            currentThrowable = currentThrowable.getCause();            
        }
        return String.format("SQL:%s\r\nMessage:%s", sql, message);
    }

    public DataAccessException() {
    }

    public DataAccessException(String message) {
        super(message);
    }
}
